package com.xywh.dakaqiandao.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.xywh.dakaqiandao.di.component.DaggerXieYiComponent;
import com.xywh.dakaqiandao.di.module.XieYiModule;
import com.xywh.dakaqiandao.mvp.contract.XieYiContract;
import com.xywh.dakaqiandao.mvp.presenter.XieYiPresenter;

import com.xywh.dakaqiandao.R;
import com.xywh.dakaqiandao.mvp.ui.entity.XieYi;

import java.util.HashMap;

import me.jessyan.armscomponent.commonres.utils.ToolbarUtils;
import me.jessyan.armscomponent.commonres.utils.CProgressDialogUtils;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;

import static com.jess.arms.utils.Preconditions.checkNotNull;


@Route(path = RouterHub.ACTIVITY_XIE_YI)
public class XieYiActivity extends BaseActivity<XieYiPresenter> implements XieYiContract.View {


    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerXieYiComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .xieYiModule(new XieYiModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_xie_yi; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        ToolbarUtils.initToolbarTitleBack(this, getString(R.string.activity_xie_yi));
        //getXieYiData();
    }

    @Override
    public void getXieYiDataSuccess(XieYi entityData) {


    }

    private void getXieYiData() {
        HashMap<String, String> map = new HashMap<>();

        mPresenter.getXieYiData(map);
    }


    @Override
    public void showLoading() {
        CProgressDialogUtils.showProgressDialog(this);
    }

    @Override
    public void hideLoading() {
        CProgressDialogUtils.cancelProgressDialog(this);
    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.makeText(this, message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }
}
